import baseService from '../baseService/index.js'
import {responseInterceptor} from './interceptor/index.js'

// 注册用户
const  registerAccountApi= async (params)=>{
    try{
        let res = await baseService.post("/register",params)
        return responseInterceptor(res)
    }catch(err){
        alert('未知异常')
    }
}

// 查询用户信息
const searchUserInfoApi = async ()=>{
    try{
        let res = await baseService.post("/searchUserInfo")
        return responseInterceptor(res)
    }catch(err){
        alert('未知异常')
    }

}


// 查找用户的随机问题
const searchUserRandomQuestionApi = async (params)=>{
    try{
        let res = await baseService.post("/searchUserRandomQuestion",params)
        return responseInterceptor(res)
    }catch(err){
        alert('未知异常')
    }
}

// 找回密码
const findpasswordApi = async (params)=>{
    try{
        let res = await baseService.post("/findPassword",params)
        return responseInterceptor(res)
    }catch(err){
        alert('未知异常')
    }
}


// 查询角色信息
const searchRoleListApi =async ()=>{
    try{
        let res = await baseService.post("/searchRoleList")
        return responseInterceptor(res)
    }catch(err){
        alert('未知异常')
    }
}


//用户绑定角色
const bindRoleApi = async (params)=>{
    try{
        let res = await baseService.post('/bindRole',params)
        return responseInterceptor(res)
    }catch(err){
        alert('未知异常')
    }
}


// 新增用户的第一个计划
const addFirstPlanApi = async (params)=>{
    try{
        let res = await baseService.post("/addFirstPlan",params)
        return responseInterceptor(res)
    }catch(err){
        alert('未知异常')
    }
}


// 新增用户的自定义角色
const addRoleMessageApi = async (params) =>{
    try{
        let res = await baseService.post('/addRoleMessage',params)
        return responseInterceptor(res)
    }catch(err){
        alert('未知异常')
    }
}


export {
    registerAccountApi,
    searchUserInfoApi,
    searchUserRandomQuestionApi,
    findpasswordApi,
    searchRoleListApi,
    bindRoleApi,
    addFirstPlanApi,
    addRoleMessageApi
}